package vis.manage.sys;

import vis.core.common.cache.Cache;
import vis.core.common.security.AuthOnlyLogin;
import vis.core.domain.db.SysOrg;
import vis.core.domain.sys.SRS;
import vis.core.service.sys.SysOrgService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/manage/system/org")
public class SysOrgController {
    @Resource
    private SysOrgService sysOrgService;

    @Resource
    private Cache<String> cache;

    @PostMapping("/insertOrg")
    public SRS<Object> insertOrg(SysOrg param) {
        boolean status = sysOrgService.insert(param);
        return SRS.bySuccess(status);
    }

    @PostMapping("/updateOrg")
    public SRS<Object> updateOrg(SysOrg param) {
        boolean status = sysOrgService.updateOrg(param);
        return SRS.bySuccess(status);
    }

    @PostMapping("/updateOrgMenu")
    public SRS<Object> updateOrgMenu(String orgId, String menuIds) {
        boolean status = sysOrgService.updateOrgMenu(orgId, menuIds);
        return SRS.bySuccess(status);
    }

    @PostMapping("/deleteOrg")
    public SRS<Object> deleteOrg(String ids) {
        boolean status = sysOrgService.delete(ids);
        return SRS.bySuccess(status);
    }

    @AuthOnlyLogin
    @PostMapping("/userHasOrg")
    public SRS<Object> userHasOrg() {
        return SRS.bySuccess(sysOrgService.userHasOrg());
    }

}
